<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
    <meta name="renderer" content="webkit">
    <title></title>
    <link rel="stylesheet" href="css/pintuer.css">
    <link rel="stylesheet" href="css/admin.css">
    <script src="js/jquery.js"></script>
    <script src="js/pintuer.js"></script>
</head>
<body>
<form method="post" action="" id="listform">
    <div class="panel admin-panel">
        <div class="panel-head"><strong class="icon-reorder">用户列表</strong></div>
        <table id="userList" class="table table-hover text-center">
            <tr>
                <th>用户ID</th>
                <th>登录账户</th>
                <th>姓名</th>
                <th>性别</th>
                <th>电话</th>
                <th>职位</th>
                <th>代表团</th>
            </tr>
        </table>
        <table id="pageInfo" class="table table-hover text-center">

        </table>
    </div>
</form>


<script>
    var pageBean;
    function appendData(showUserList) {
        $.each(showUserList, function (index, showUser) {
            var gender
            if(showUser.gender==0){
                gender="男"
            }else if(showUser.gender==1){
                gender="女"
            }else{
                gender="其他"
            }
            var data = "<tr class='mydata'>" +
                "<td>" + showUser.uid + "</td>" +
                "<td>" + showUser.userName + "</td>" +
                "<td>" + showUser.userRealName + "</td>" +
                "<td>" + gender + "</td>" +
                "<td>" + showUser.telPhone + "</td>" +
                "<td>" + showUser.staffName + "</td>" +
                "<td>" + showUser.delegationName + "</td>" +
                "</tr>"
            $("#userList").append(data);
        })
    }
    $(function () {
        $.post(
            "/MangeUserController/findAllUser",
            "pageCode=1",
            function (resp) {
                pageBean = resp.t;
                var showUserList = resp.t.datas;
                appendData(showUserList);
                appendPageInfo();
            },
            "json"
        );
    })
    function nextP(pageCode){
        $("#userList tr").remove(".mydata")
        $.post(
            "/MangeUserController/findAllUser",
            "pageCode="+pageCode,
            function (resp) {
                pageBean = resp.t;
                var showUserList = resp.t.datas;
                appendData(showUserList);
                $("#pageTr").remove();
                appendPageInfo();
            },
            "json"
        )
    }
    function appendPageInfo(){
        var data2 = "<tr id='pageTr'>\n" +
            "                <td colspan=\"8\">\n" +
            "                    <div id=\"pagelist\" class=\"pagelist\">\n" +
            "                        <a href=\"javascript:void(0)\" id=\"firstPage\" onclick=\"nextP("+(1)+")\">首页</a>\n" +
            "                        <a href=\"javascript:void(0)\" id=\"previousPage\" onclick=\"nextP("+((pageBean.currentPage-1)<1?1:(pageBean.currentPage-1))+")\">上一页</a>\n" +
            "                        <a href=\"javascript:void(0)\" id=\"nextPage\" onclick=\"nextP("+((pageBean.currentPage+1)>(pageBean.totalRecords)?(pageBean.totalRecords):(pageBean.currentPage+1))+")\">下一页</a>\n" +
            "                        <a href=\"javascript:void(0)\" id=\"lastPage\" onclick=\"nextP("+(pageBean.totalRecords)+")\">尾页</a>\n" +
            "                    </div>\n" +
            "                </td>\n" +
            "            </tr>";
        $("#pageInfo").append(data2)
    }
</script>
</body>
</html>